import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from logic.PathConfig import *
import Config


def RunFTPServer():
    authorizer = DummyAuthorizer()

    ftpPath = GetAbsPath() + "/../../" + updateFilePath

    authorizer.add_user( Config.username,  Config.password, ftpPath)

    handler = FTPHandler
    handler.authorizer = authorizer
    print("传输服务器已启动..." + str(Config.curIP) + " " +  str(Config.ftpPort )) 
    server = FTPServer(( Config.curIP, Config.ftpPort), handler)
    server.serve_forever()

if __name__ == '__main__':
    RunFTPServer()